#ifndef _DAG_FRAME_OP_FACTORY_H_
#define _DAG_FRAME_OP_FACTORY_H_

#include "dag.h"
#include "dag_singleton.h"
#include "dag_threading.h"

#include <memory>
#include <string>
#include <map>

/*
 * FrameOpFactory::instance().induct(name, func);
 */

namespace dag {
	
	//typedef std::auto_ptr<FrameOperator> (*inflate_fp)(std::istream& bStream);
	
	class DAG_LOCAL FrameOpFactoryImpl {
		FrameOpFactoryImpl(const FrameOpFactoryImpl& copy);
		FrameOpFactoryImpl& operator=(const FrameOpFactoryImpl& rhs);
	public:
		
		void induct(const std::string& className, 
					frame_op_inflate_fp inflatorFunc);
		std::auto_ptr<FrameOperator> inflate(const std::string& frameOperatorID,
											 std::istream& bStream);
	protected:
		FrameOpFactoryImpl();
		
	private:
		Mutex m_InflatorsMutex;
		std::map<std::string, frame_op_inflate_fp>  m_Inflators;
	};	
	
	typedef Singleton<FrameOpFactoryImpl> FrameOpFactory;
}

#endif